package com.cleaningcloud.erp.api.factory;

import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.erp.api.RemoteCommodityService;
import com.cleaningcloud.erp.api.domain.ErpCommodityStockAlter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteCommodityFallbackFactory implements FallbackFactory<RemoteCommodityService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteWareFallbackFactory.class);

    @Override
    public RemoteCommodityService create(Throwable throwable) {
        log.error("进销存商品管理服务调用失败:{}", throwable.getMessage());
        return new RemoteCommodityService() {

            @Override
            public AjaxResult addWare(ErpCommodityStockAlter erpCommodityStockAlter, String source) {
                return AjaxResult.error("新增库存商品变更信息失败:" + throwable.getMessage());
            }
        };
    }
}
